﻿<UserControl x:Class="ClientOverflow.UserControls.UsersList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:ComponentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <CollectionViewSource Source="{Binding Users}" x:Key="usersSource">
            <CollectionViewSource.SortDescriptions>
                <ComponentModel:SortDescription
                    PropertyName="Votes" 
                    Direction="Descending" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
    </UserControl.Resources>
    <ListBox ItemsSource="{Binding Source={StaticResource usersSource}}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding User.Name}"/>
                    <TextBlock Text=" x "/>
                    <TextBlock Text="{Binding Votes}"/>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
</UserControl>
